package com.edu.bcht.controller;


import com.edu.bcht.bean.User;
import com.edu.bcht.service.UserService;
import com.edu.bcht.test01.mapper.User01Mapper;
import com.edu.bcht.test02.mapper.User02Mapper;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class IndexController {
      private Logger log = Logger.getLogger(IndexController.class);

    @Autowired
    private User01Mapper user01Mapper;
    @Autowired
    private User02Mapper user02Mapper;
    @Autowired
    private UserService userService;
    /**
     * 清楚缓存
     */
    @Autowired
    private CacheManager cacheManager;
     @RequestMapping("/index")
    public  String index(){
        user01Mapper.insert(8,"test01","25");
        user02Mapper.insert(8,"test02","25");
        return "success";
    }
     @RequestMapping("/test")
    public String test() {
         userService.insert1And2();
       return  "test";
    }
  @RequestMapping("/test01")
    public String test01() {
        log.debug("进入test01");
       return  "test01";
    }
    @RequestMapping("/getAll")
  public List<User> getAll(){
       return user01Mapper.getAll();
  }
    @RequestMapping("/remoKey")
    public void remoKey() {
        log.info(cacheManager.getCacheNames());
        cacheManager.getCache("baseCache").clear();
    }
}
